<template>
  <div>
    <eagle-list
      showTab
      :tabData="tabData"
      @initActive="_initActive"
      @bindData="bindData"
      allowSearch
      placeholder="请输入汇编名称,最近修改人搜索"
      ref="eaglelist"
    >
      <div v-if="this.active === 0">
        <div v-if="GuidelineEntrustedRegList != null">
          <eagle-cell
            style="margin-top: 10px"
            class="card"
            v-for="(item, index) in GuidelineEntrustedRegList"
            :key="index"
          >
            <div>
              <div @click="goDetail(item, '')">
                <eagle-row>
                  <eagle-col>
                    <b style="font-size: 13px">{{ item.RequirementName }}</b>
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_type.png"
                      alt=""
                    />制度名称：{{ item.RegulationName }}
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />要素：
                  <div
                    span="24 "
                    style="display: block"
                    v-html="getGB(item)"
                  ></div>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                    />最近修改人：{{ item.EditChnName }}
                  </eagle-col>
                </eagle-row>

                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />最近修改日期：{{ item.EditDate| formatDateTime }}
                  </eagle-col>
                </eagle-row>
                <eagle-file-read-only
                  :attachs="item.MainAttach"
                  :labelName="'文件:'"
                ></eagle-file-read-only>
              </div>
            </div>
          </eagle-cell>
        </div>
        <div v-if="RegulationOperationList != null">
          <eagle-cell
            style="margin-top: 10px"
            class="card"
            v-for="(item, index) in RegulationOperationList"
            :key="index"
          >
            <div>
              <div @click="goDetail(item, '')">

                <eagle-row>
                  <eagle-col>
                    <b style="font-size: 13px">{{ item.CompileName }}</b>
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                    />最近修改人：{{ item.EditChnName }}
                  </eagle-col>
                </eagle-row>

                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />最近修改日期：{{ item.EditDate | formatDateTime }}
                  </eagle-col>
                </eagle-row>
                <eagle-file-read-only
                  :attachs="item.MainAttach"
                  :labelName="'签发版本:'"
                ></eagle-file-read-only>
                <eagle-file-read-only
                  :attachs="item.Attachs2"
                  :labelName="'附件:'"
                ></eagle-file-read-only>
              </div>
            </div>
          </eagle-cell>
        </div>
      </div>
      <div v-if="this.active === 1">
        <div v-if="GuidelineEntrustedRegList != null">
          <eagle-cell
            style="margin-top: 10px"
            class="card"
            v-for="(item, index) in GuidelineEntrustedRegList2"
            :key="index"
          >
            <div>
              <div @click="goDetail(item, 'isSignature')">
                <eagle-row>
                  <eagle-col>
                    <b style="font-size: 13px">{{ item.RequirementName }}</b>
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="30">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_type.png"
                      alt=""
                    />制度名称：{{ item.RegulationName }}
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />要素：
                  <template #input> </template>
                  <eagle-col
                    span="20"
                    v-html="getGB(item)"
                  > </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                    />最近修改人：{{ item.EditChnName }}
                  </eagle-col>
                </eagle-row>

                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />最近修改日期：{{ item.EditDate | formatDateTime }}
                  </eagle-col>
                </eagle-row>

                <eagle-file-read-only
                  :attachs="item.MainAttach"
                  :labelName="'文件:'"
                ></eagle-file-read-only>
              </div>
            </div>
          </eagle-cell>
        </div>
        <div v-if="RegulationOperationList2 != null">
          <eagle-cell
            style="margin-top: 10px"
            class="card"
            v-for="(item, index) in RegulationOperationList2"
            :key="index"
          >
            <div @click="goDetail(item, 'forSignature')">
              <eagle-row>
                <eagle-col>
                  <b style="font-size: 13px">{{ item.CompileName }}</b>
                </eagle-col>
              </eagle-row>
              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="24">
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_user.png"
                    alt=""
                  />最近修改人：{{ item.EditChnName }}
                </eagle-col>
              </eagle-row>

              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="24">
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />最近修改日期：{{ item.EditDate | formatDateTime }}
                </eagle-col>
              </eagle-row>
              <eagle-file-read-only
                :attachs="item.MainAttach"
                :labelName="'待签字文件:'"
              ></eagle-file-read-only>
              <eagle-file-read-only
                :attachs="item.Attachs2"
                :labelName="'附件:'"
              ></eagle-file-read-only>
            </div>
          </eagle-cell>
        </div>
      </div>
    </eagle-list>
  </div>

</template>

<script>
import store from "@/store/index";
export default {
  data() {
    return {
      title1: this.$route.query.title1,
      title2: this.$route.query.title2,
      titleCode: this.$route.query.titleCode,
      GuidelineEntrustedRegList: [],
      GuidelineEntrustedRegList2: [],
      RegulationOperationList: [],
      RegulationOperationList2: [],
      MainAttach: {},
      tabData: [],
      active: 0,
    };
  },
  created() {
    if (this.$route.query.titleCode == "GuidelineReg") {
      this.tabData.push(
        {
          title: this.title1,
          url: "/GuidelineReg/GetPageData",
          isPage: true,
          params: {
            dataType: "Publish",
            dCode: -1,
          },
        },
        {
          title: this.title2,
          url: "/GuidelineReg/GetPageData",
          isPage: true,
          params: {
            dataType: "NotSign",
            dCode: -1,
          },
        }
      );
    } else if (this.$route.query.titleCode == "GuidelineRegCommonCompile") {
      this.tabData.push(
        {
          title: this.title1,
          url: "/GuidelineRegCommonCompile/GetPageData",
          isPage: true,
          params: {
            dataType: "Publish",
            dCode: -1,
          },
        },
        {
          title: this.title2,
          url: "/GuidelineRegCommonCompile/GetPageData",
          isPage: true,
          params: {
            dataType: "NotSign",
            dCode: -1,
          },
        }
      );
    }
    this.calcTitle();
  },
  methods: {
    _initActive(active) {
      this.active = active;
    },
    bindData(data) {
      let title;
      let originType = this.$route.query.titleCode;
      if (originType == "GuidelineReg") {
        if (this.active === 0) {
          this.GuidelineEntrustedRegList = data;
        } else if (this.active === 1) {
          this.GuidelineEntrustedRegList2 = data;
        }
        title = "规章制度(程序)";
        store.commit("updateTitle", title);
      } else if (originType == "GuidelineRegCommonCompile") {
        if (this.active === 0) {
          this.RegulationOperationList = data;
        } else {
          this.RegulationOperationList2 = data;
        }
        title = "安全生产制度汇编";
      }
      store.commit("updateTitle", title);
    },
    _fileUploadCb(attachs) {
      this.form.Attach = attachs;
    },
    calcTitle() {
      let originType = this.$route.query.titleCode;
      let title;
      if (originType == "GuidelineReg") {
        title = "规章制度(程序)";
      } else if (originType == "GuidelineRegCommonCompile") {
        title = "安全生产制度汇编";
      }
      console.log("https======originTypeAAA=>", title);
      store.commit("updateTitle", title);
    },
    getGB(item) {
      var str = "";
      var str1 = "";
      var str2 = "";
      var str3 = "";
      if (item.StandardizationClauseNo) {
        str1 =
          "\xa0\xa0\xa0\xa0\xa0 GB/T33000  " +
          item.StandardizationClauseNo +
          "(" +
          item.StandardizationClauseName +
          ")<br />";
      }
      if (item.HealthClauseNo) {
        str2 =
          "\xa0\xa0\xa0\xa0\xa0 ISO45001  " +
          item.HealthClauseNo +
          "(" +
          item.HealthClauseName +
          ")<br />";
      }
      if (item.EnvironmentClauseNo) {
        str3 =
          "\xa0\xa0\xa0\xa0\xa0 ISO14001  " +
          item.EnvironmentClauseNo +
          "(" +
          item.EnvironmentClauseName +
          ")";
      }
      str = str1 + str2 + str3;
      return str;
    },

    goFile(attachCode) {
      this.$router.push("/Attach/AatachDetail?attCode=" + attachCode);
    },
    goDetail(item, isSignature) {
      if (this.titleCode == "GuidelineReg") {
        this.$router.push({
          path: "/RegulatoryFramework/Detail",
          query: {
            id: item.ID,
            titleCode: this.$route.query.titleCode,
            isSignature: isSignature,
          },
        });
      } else if (this.$route.query.titleCode == "GuidelineRegCommonCompile") {
        this.$router.push({
          path: "/RegulatoryFramework/Detail",
          query: {
            id: item.ID,
            titleCode: this.$route.query.titleCode,
            isSignature: isSignature,
          },
        });
      }
    },
  },
};
</script>

<style lang="less" scoped>
.van-cell.card {
  border-radius: 0.16rem;
  background-color: #ffffff;
  padding: 0.26667rem;
  margin-top: 0.26667rem;
  margin-left: 0.26667rem;
  margin-right: 0.26667rem;
  width: auto;
}
</style>
